package com.kun.util;

import org.springframework.core.NamedThreadLocal;

/**
 * 租户上下文
 * @author kun.li
 */
public class TenantContext {

    private static final ThreadLocal<String> CONTEXT = new NamedThreadLocal<>("tenant");

    public static void setTenantId(String tenantId) {
        CONTEXT.set(tenantId);
    }

    public static String getTenantId() {
        return CONTEXT.get();
    }

    public static void clear() {
        CONTEXT.remove();
    }
}
